home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A)[a].zip / Nibble Volume 12, No. 01 (1991-01)(MindCraft Publishing)(Side A)[a].po / PACK.S < prev    next >
Text File  |  1996-12-24  |  5KB  |  126 lines

  1. *--------------------------------*
  2. *  Super Res_PACKBYTES format    *
  3. * picture packer by Peter Stubbs *
  4. *--------------------------------*
  5. *   MERLIN 816 ASSEMBLER        *
  6. *--------------------------------*
  7. *     Copyright (C) 1991         *
  8. *    Mindcraft Publ. Corp.       *
  9. *--------------------------------*
  10.  
  11. *          PLEASE NOTE:
  12. *          -----------
  13. *   1. Program is relocatable & runs at any address
  14. *
  15. *   2. The picture to be packed must already be in
  16. *      the Super Res screen buffer ($E12000-$E19FFF)
  17. *
  18. *   3. The packed pic is saved at $1400 in bank 00
  19.  
  20.  
  21. LINSAVE   EQU $3         ;To hold value at NEWVIDEO
  22. SIZEPTR   EQU $4         ;Size of SuperRes pic
  23. STARTPTR  EQU $7         ;Ptr to start of pic
  24. PROMPT    EQU $33        ;Current screen prompt
  25. BUFFSIZE  EQU $EB        ;Size of data to pack
  26. NUMBYTES  EQU $ED        ;Number of bytes packed
  27. PTR       EQU $FC        ;For indexed indirect mode
  28. ERRCODE   EQU $FE        ;Pack error if non zero
  29. NEWVIDEO  EQU $C029
  30. COUT      EQU $FDED      ;ROM Character output
  31. PRNTAX    EQU $F941      ;ROM Hex print
  32.  
  33. SIZE      EQU $9400-$1400 ;Max size of packed pic
  34. BUFFADR   EQU $001400    ;Output buffer=$1400 bank 00
  35.  
  36.           ORG $300
  37.           TR ADR
  38. PAK       LDA NEWVIDEO
  39.           STA LINSAVE    ;Save for later
  40.           ORA #%01000000 ;Linear mode on, but not
  41.           STA NEWVIDEO   ; Super res mode
  42.           CLC            ;Prepare to enter CPU
  43.           XCE            ; native mode with
  44.           REP #$30       ; full 16 bit registers
  45.           MX %00         ;Tell Merlin
  46.  
  47. * SETUP VALUES TO PACK PICTURE DATA
  48.  
  49.           LDA #$A000-$2000 ;Size of pic & pal data
  50.           STA SIZEPTR
  51.           LDA #<$E12000  ;Start of pic data
  52.           STA STARTPTR
  53.           LDA #^$E12000
  54.           STA STARTPTR+2
  55.  
  56. * Code to pack the specified data range
  57.  
  58.           PEA $0000      ;Space for result
  59.           PEA #^STARTPTR ;Pointer to word with start
  60.           PEA #<STARTPTR ; of area to pack
  61.           PEA #^SIZEPTR  ;Pointer to word with size
  62.           PEA #<SIZEPTR  ; of area to pack
  63.           PEA #^BUFFADR  ;Address of output buffer
  64.           PEA #<BUFFADR  ; ($1400 in bank 00)
  65.           PEA #<SIZE     ;Size of output buffer
  66.           LDX #$2603     ;_PackBytes Tool call
  67.           JSL $E10000    ;Call the Tool locator
  68.           PLA            ;Get no. of bytes packed
  69.           STA NUMBYTES   ;No of bytes packed
  70.           LDA STARTPTR   ;Is all of picture packed?
  71.           CMP #<$E1A000  ;Result checked later
  72.           PHP            ;Save result of compare
  73.           SEC            ;Emulation mode back on
  74.           XCE
  75.           MX %11
  76.           LDA LINSAVE    ;Restore video state
  77.           STA NEWVIDEO
  78.           STZ ERRCODE    ;Start with error code 0
  79.           PLP            ;Get result of compare back
  80.           BEQ NOERR      ;If were equal then all done
  81.           INC ERRCODE    ;Else flag a packing error
  82.  
  83. * Determine how to display results
  84.  
  85. NOERR     LDA PROMPT     ;Get current screen prompt
  86.           CMP #"]"       ;Applesoft?
  87.           BEQ PRINTIT    ;If yes display on screen
  88.           CMP #"*"       ;Monitor?
  89.           BNE EXIT2      ;No, we came from another
  90.                          ; program so don't display
  91.  
  92. * Display results on screen for user
  93.  
  94. PRINTIT   LDX #$0        ;So we use PTR as our index
  95.           LDA ERRCODE    ;Get error code
  96.           BEQ OK         ;If no pack error, else
  97.           PER ERR        ; push text loc. onto stack
  98.           PLA            ;Get low byte
  99.           STA PTR        ; and set up PTR index
  100.           PLA            ;Get high byte
  101.           STA PTR+1      ; and set up rest of index
  102. ELOOP     LDA (PTR,X)    ;Get character to display
  103.           BEQ EXIT2      ;If 00 then at end of text
  104.           JSR COUT       ; else print it
  105.           INC PTR        ;Point at next char of text
  106.           BRA ELOOP      ;ALWAYS (gets next character)
  107. OK        PER MSG        ;Push loc. of BSAVE message
  108.           PLA            ; then get low byte from stack
  109.           STA PTR        ; and set up PTR index
  110.           PLA            ;Get high byte
  111.           STA PTR+1      ; and set up rest of index
  112. MLOOP     LDA (PTR,X)    ;print BSAVE details
  113.           BEQ EXIT       ;If 00 then at end of text
  114.           JSR COUT       ; else print it
  115.           INC PTR        ;Point at next char of text
  116.           BRA MLOOP      ;ALWAYS
  117. EXIT      LDA NUMBYTES+1 ;Use ROM PRNTAX routine
  118.           LDX NUMBYTES   ; to print L$ value
  119.           JSR PRNTAX
  120. EXIT2     RTS            ;Return to caller
  121. MSG       ASC "BSAVE(Filename),A$1400,L$"
  122.           HEX 00
  123. ERR       ASC "Pack err"
  124.           HEX 8700
  125.           lst off
  126.